home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / python2.6 / sqlite3 / dump.pyc (.txt) < prev   
Python Compiled Bytecode  |  2009-11-11  |  2KB  |  47 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4.  
  5. def _iterdump(connection):
  6.     '''
  7.     Returns an iterator to the dump of the database in an SQL text format.
  8.  
  9.     Used to produce an SQL dump of the database.  Useful to save an in-memory
  10.     database for later restoration.  This function should not be called
  11.     directly but instead called from the Connection method, iterdump().
  12.     '''
  13.     cu = connection.cursor()
  14.     yield 'BEGIN TRANSACTION;'
  15.     q = "\n        SELECT name, type, sql\n        FROM sqlite_master\n            WHERE sql NOT NULL AND\n            type == 'table'\n        "
  16.     schema_res = cu.execute(q)
  17.     for table_name, type, sql in schema_res.fetchall():
  18.         if table_name == 'sqlite_sequence':
  19.             yield 'DELETE FROM sqlite_sequence;'
  20.         elif table_name == 'sqlite_stat1':
  21.             yield 'ANALYZE sqlite_master;'
  22.         elif table_name.startswith('sqlite_'):
  23.             continue
  24.         else:
  25.             yield '%s;' % sql
  26.         res = cu.execute("PRAGMA table_info('%s')" % table_name)
  27.         column_names = [ str(table_info[1]) for table_info in res.fetchall() ]
  28.         q = 'SELECT \'INSERT INTO "%(tbl_name)s" VALUES('
  29.         [] += []([ "'||quote(" + col + ")||'" for col in column_names ])
  30.         q += ")' FROM '%(tbl_name)s'"
  31.         query_res = cu.execute(q % {
  32.             'tbl_name': table_name })
  33.         for row in query_res:
  34.             yield '%s;' % row[0]
  35.             ','.join
  36.         
  37.     
  38.     q = "\n        SELECT name, type, sql\n        FROM sqlite_master\n            WHERE sql NOT NULL AND\n            type IN ('index', 'trigger', 'view')\n        "
  39.     schema_res = cu.execute(q)
  40.     for name, type, sql in schema_res.fetchall():
  41.         yield '%s;' % sql
  42.         q
  43.     
  44.     yield 'COMMIT;'
  45.     []
  46.  
  47.